#!/usr/bin/env python
import pygame
from pygame.locals import *
from sys import exit
from random import randint

background_image_filename = 'sushiplate.jpg'
mouse_image_filename = 'fugu.png'
count = 1
pygame.init()
screen = pygame.display.set_mode((640, 480),0, 32)
screen.fill((149,202,200))
pygame.display.set_caption("Hello, World!")

background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()

def displayLabel(c,p):
    label = pygame.font.SysFont("monaco",46)
    label_suf = label.render(c, True, (0, 0, 0), (255, 255, 255))
    screen.blit(label_suf,p)

def generatRandomSpots():
    """@todo: Docstring for generatRandomSpots.
    :returns: @todo

    """
    rand_col = (randint(0, 255), randint(0, 255), randint(0, 255))
    for _ in xrange(255):
        rand_pos = (randint(0,640),randint(0,480))
        screen.set_at(rand_pos,rand_col)

def movingPointer():
    x, y = pygame.mouse.get_pos()
    x-= mouse_cursor.get_width() / 2
    y-= mouse_cursor.get_height() / 2
    screen.blit(mouse_cursor, (x, y))

def makeBackground():
    screen.blit(background, (0,0))

def makeRandomRect():
    """@todo: Docstring for makeRect.
    :returns: @todo
    """
#    myrect = pygame.Surface((100,100))
#    myrect.fill((5,5,5))
    rc = (randint(0,255), randint(0,255), randint(0,255))
    rp = (randint(0,639), randint(0,479))
    rs = (639-randint(rp[0], 639), 479-randint(rp[1], 479))
    cell = pygame.draw.rect(screen, rc, Rect(rp, rs))

def makeRect(rc,rp,rs):
    """@todo: Docstring for makeRect.
    :returns: @todo
    """
    pygame.draw.rect(screen, rc, Rect(rp, rs))
#game starting point

def makeGrid(i,j):
    rc = (randint(0,255), randint(0,255), randint(0,255))
    rs = (100,100)
    rp = (100*i+10,100*j+10)
    makeRect(rc,rp,rs)
    displayLabel("0",rp)


def start():
    for i in list(range(6)):
        for j in list(range(6)):
            makeGrid(i,j)
            j=j+1
        i=i+1


start()

# updating game frameings

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()

    if event.type == KEYDOWN:
        if event.key == K_f:
            screen = pygame.display.set_mode((640, 480),FULLSCREEN, 32)
        elif event.key == K_l:
            displayLabel("X",(400,400))
            
        else:
            screen = pygame.display.set_mode((640, 480),0, 32)

    if event.type == MOUSEBUTTONDOWN:
        print()

    pygame.display.update()

